import * as actionTypes from './constants'
import { getBannersDetail, getIntroSongsDetail, getPrivateDetail, getSongsDetail } from '../../../service/service'


export const changeBannerAction = (res) => ({
  type: actionTypes.CHANGE_BANNERS,
  banners: res.banners
})

export const getBanners = () => {
  return dispatch => {
    getBannersDetail().then(res => {
      dispatch(changeBannerAction(res))
    })
  }
}


export const changeIntroAction = (res) => ({
  type: actionTypes.CHANGE_INTRO_SONGS,
  introSongs: res.result
})

export const getIntroSongs = () => {
  return dispatch => {
    getIntroSongsDetail(10).then(res => {
      dispatch(changeIntroAction(res))
    })
  }
}


export const changePrivateAction = (res) => ({
  type: actionTypes.CHANGE_PRIVATE_LIST,
  privateList: res.result
})

export const getPrivate = () => {
  return dispatch => {
    getPrivateDetail().then(res => {
      dispatch(changePrivateAction(res))
    })
  }
}

export const changeNewSongsAction = (res) => ({
  type: actionTypes.CHANGE_NEW_SONGS,
  newSongs: res.result
})

export const getNewSongs = () => {
  return dispatch => {
    getSongsDetail().then(res => {
      dispatch(changeNewSongsAction(res))
    })
  }
}